home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s4.arc
/
PIBTERM.BIG
next >
Wrap
Text File
|
1987-09-08
|
17KB
|
414 lines
{Main module of program PIBTERM.BIG}
{.N PT4KERM}
{.N PT4XMOD}
{.N PT4EDIT}
{.N PT4HOST}
{.N PT4USER}
{.N PT4T4010}
{.N PT4SCRI}
{.N PT4DIAL}
{.N PT4UTIL}
{.N PT4INIT}
{.N PT4UTIL}
{.N PT4TERM}
{.N PT4GOSSI}
(*$C-,V-,U-,R-,K-*)
PROGRAM PibTerm;
(*----------------------------------------------------------------------*)
(* PibTerm --- Terminal Emulator in Turbo Pascal *)
(*----------------------------------------------------------------------*)
(* *)
(* Author: (c) 1985, 1986, 1987 by Philip R. Burns *)
(* *)
(* Date: January, 1987 *)
(* Version: 1.0 (January, 1985) *)
(* 2.0 (July, 1985) *)
(* 3.0 (October, 1985) *)
(* 3.2 (November, 1985) *)
(* 4.0 (September, 1987) *)
(* *)
(* Systems: For MS-DOS on IBM PCs and close compatibles only. *)
(* Note: I have checked these on under MSDOS 2.x/3.x *)
(* on a variety of IBM PCs and clones. *)
(* *)
(* Overview: This program provides a comprehensive terminal emulation *)
(* and remote communications facility. PibTerm emulates *)
(* several different terminals. *)
(* *)
(* PibTerm allows for file transfer facilities using *)
(* many different protocols. *)
(* *)
(* The commands and general program use follow that of other *)
(* popular communications programs like PC-Talk and Qmodem. *)
(* *)
(* PibTerm also provides a simple host communications *)
(* facility like a mini-BBS. *)
(* *)
(*----------------------------------------------------------------------*)
(* *)
(* Restriction *)
(* ----------- *)
(* *)
(* You may use this code only for NON COMMERCIAL purposes *)
(* unless you explicitly obtain my permission. I take a dim *)
(* view of others making money on my work and those of other *)
(* people whose code I've inserted here. *)
(* *)
(* Please feel free to add new features. I wrote this *)
(* program to give people a useful and usable basic terminal *)
(* facility, and to show how Turbo Pascal can be used for *)
(* asynchronous communications, menu display, windowing, and *)
(* so on. I hope that you find this program useful -- and, *)
(* if you expand upon it, please upload your extensions so *)
(* that all of us can enjoy them! *)
(* *)
(*----------------------------------------------------------------------*)
(* *)
(* Suggestions for improvements or corrections are welcome. *)
(* Please leave messages on Gene Plantz's BBS (312) 882 4145 *)
(* or Ron Fox's BBS (312) 940 6496. *)
(* *)
(*----------------------------------------------------------------------*)
(* Global const/type/var definitions *)
{$I PIBTDCL1.GLO }
{$I PIBTDCL2.GLO }
(* Turbo extender definitions *)
{$I BIGTURBO.VAR }
(* Time of day for status line *)
{$I FASTTIME.MOD }
(* Write to status line *)
{$I WRITESTA.MOD }
(* Updates status line *)
{$I UPDATEST.MOD }
(* Read keyboard driver *)
{$I RDKEYBRD.MOD }
(* Error handler interface *)
{$I TRAPERRO.MOD }
{Includes for exported shells of other modules}
{$I LOADMOD.IN1 }
{$I PT4KERM.EXP }
{$I PT4XMOD.EXP }
{$I PT4EDIT.EXP }
{$I PT4HOST.EXP }
{$I PT4USER.EXP }
{$I PT4INIT.EXP }
{$I PT4SETP.EXP }
{$I PT4UTIL.EXP }
{$I PT4SCRI.EXP }
{$I PT4TERM.EXP }
{$I PT4GOSSI.EXP }
{$I PT4T4010.EXP }
{executable code local to this module follows}
PROCEDURE Print_Spooled_File;
FORWARD;
PROCEDURE Error_Handler( ErrNo , ErrAddr : INTEGER );
FORWARD;
FUNCTION Color_Screen_Active : BOOLEAN;
FORWARD;
PROCEDURE UnloadAllModules;
FORWARD;
(* Intercepts Turbo's HALT *)
{$I PIBHALT.MOD }
(* Critical error interrupt handler *)
{$I INT24.MOD }
(* Convert hex string to decimal # *)
{$I HEXTODEC.MOD }
(* Convert decimal # to hex string *)
{$I DECTOHEX.MOD }
(* Convert integer to string *)
{$I ITOS.MOD }
(* Multitasker interface routines *)
{$I PIBMDOS.MOD }
(* Read character from keyboard *)
{$I READKBD.MOD }
(* Get string from DOS environment *)
{$I GETENVST.MOD }
(* Do a "press any" question *)
{$I PRESSANY.MOD }
(* Find minimum/maximum of numbers *)
{$I MINMAX.MOD }
(* Duplicate a character into string *)
{$I DUPL.MOD }
(* Trim blanks from end of string *)
{$I TRIM.MOD }
(* Trim blanks from front of string *)
{$I LTRIM.MOD }
(* Extract substring of a string *)
{$I SUBSTR.MOD }
(* Convert string to uppercase *)
{$I UPPERCAS.MOD }
(* Copy string to array of char *)
{$I COPYSTOA.MOD }
(* Read string with control chars *)
{$I READCTRL.MOD }
(* Write string with control chars *)
{$I WRITCTRL.MOD }
(* Adjust time for am/pm difference *)
{$I ADJUSTHR.MOD }
(* Timer interface routines *)
{$I PIBTIMER.MOD }
(* Asynchronous I/O interface *)
{$I PIBASYN1.MOD }
{$I PIBASYN2.MOD }
{$I PIBASYN3.MOD }
(* Redefine Int 9 keyboard handler *)
{$I KBDINTP.MOD }
(* Open file for append *)
{$I OPENFORA.MOD }
(* Get maximum available storage *)
{$I MAXBLOCK.MOD }
(* Update review pointers *)
{$I UPDATERE.MOD }
(* Write time stamped string to log *)
{$I WRITELOG.MOD }
(* Screen management routines *)
{$I PIBSCRN1.MOD }
{$I PIBSCRN2.MOD }
{$I WRITECXY.MOD }
{$I MOVETOXY.MOD }
{$I PIBSCRN3.MOD }
(* Redefine Int 10 video handler *)
{$I VIDINTP.MOD }
(* Scroll portion of screen *)
{$I SCROLL.MOD }
(* Clear out current window *)
{$I CLEARWIN.MOD }
(* Pop-up menu routines *)
{$I PIBMENUS.MOD }
(* MS DOS directory routines *)
{$I PIBDIR.MOD }
(* File handle I/O routines *)
{$I PIBFHIO.MOD }
(* Send string to modem *)
{$I SENDMODE.MOD }
(* Print character from spool file *)
{$I PRINTSPO.MOD }
(* Get yes/no answer *)
{$I YESNO.MOD }
(* Hangup the phone -- Alt_H *)
{$I HANGUP.MOD }
(* Generate a menu *)
{$I MAKEMENU.MOD }
{$I MAKEMEND.MOD }
(* Get stack pointer *)
{$I STACKPOI.MOD }
(* Stuff keyboard buffer *)
{$I STUFFKBD.MOD }
(* Edit a string *)
{$I EDITSTRI.MOD }
(* Read and edit a string *)
{$I READEDIS.MOD }
(* Read a number *)
{$I READNUMB.MOD }
(* Overlay module loader interface *)
{$I MYLOADO.MOD }
(* DOS jump interface *)
{$I DOSJUMP.MOD }
(* Auto find file name *)
{$I GETAUTOF.MOD }
(* Display transfer types menu *)
{$I DISPLYTT.MOD }
(* Get upload protocol -- Alt_S *)
{$I GETUPLOA.MOD }
(* Get download protocol -- Alt_R *)
{$I GETDOWNL.MOD }
(* Signal end of transfer *)
{$I SIGENDTR.MOD }
(* Transfer file through batch file *)
{$I TRANSBAT.MOD }
(* General file transfer handler *)
{$I PIBUPDOW.MOD }
(* General upload handler -- Alt_S *)
{$I PIBUPLOD.MOD }
(* General download handler -- Alt_R *)
{$I PIBDWLOD.MOD }
(* Initialize directories *)
{$I INITOVLY.MOD }
(* Initialize PibTerm interface *)
{$I INITTERM.MOD }
(* Finish execution -- Alt_X *)
{$I FINITERM.MOD }
(* General error handler *)
{$I ERRORHAN.MOD }
(* Get command line parameters *)
{$I GETCOMAN.MOD }
(* Define a key *)
{$I DEFINEKY.MOD }
(*----------------------------------------------------------------------*)
PROCEDURE Terminal_Emulations;
(* STRUCTURED *) CONST
PibTerm_Stops : STRING[18] = '*** PibTerm stops.';
(*----------------------------------------------------------------------*)
PROCEDURE Load_User_Terminal;
VAR
User_Number : INTEGER;
BEGIN (* Load_User_Terminal *)
User_Number := SUCC( ORD( Terminal_To_Emulate ) - ORD( User1 ) );
IF ( POS( '.CHN', UpperCase( User_Term_Name[User_Number] ) ) > 0 ) THEN
BEGIN
IF MyLoadOverlay( 2, PT4USER, User_Term_Name[User_Number] ) THEN
BEGIN
Emulate_User_Terminal;
UnloadEmulator;
END
ELSE
Terminal_To_Emulate := Saved_Gossip_Term;
END
ELSE
Emulate_General_Terminal;
END (* Load_User_Terminal *);
(*----------------------------------------------------------------------*)
BEGIN (* Terminal_Emulations *)
(* Load terminal emulation module *)
IF ( NOT MyLoadOverlay( 1, PT4TERM, 'PT4TERM.CHN' ) ) THEN
BEGIN
WRITELN(PibTerm_Stops);
Halt( 1 );
END;
REPEAT
CASE Terminal_To_Emulate OF
Ansi : Emulate_Ansi( FALSE );
VT100 : Emulate_Ansi( TRUE );
VT52,
ADM3a,
ADM5,
TV925,
Dumb : Emulate_General_Terminal;
Gossip : IF MyLoadOverlay( 2, PT4GOSSI, 'PT4GOSSI.CHN' ) THEN
BEGIN
Emulate_Gossip;
UnloadEmulator;
END
ELSE
BEGIN
Terminal_To_Emulate := Saved_Gossip_Term;
Gossip_Mode_On := FALSE;
END;
HostMode : BEGIN
IF MyLoadOverlay( 1, PT4HOST, 'PT4HOST.CHN' ) THEN
BEGIN
Emulate_Host;
IF ( NOT MyLoadOverlay( 1, PT4TERM, 'PT4TERM.CHN' ) ) THEN
BEGIN
WRITELN('*** Can''t load main terminal emulator module.');
WRITELN(PibTerm_Stops);
PibTerm_Done := TRUE;
END;
END
ELSE
BEGIN
Terminal_To_Emulate := Saved_Gossip_Term;
Host_Mode := FALSE;
END;
END;
User1..User5 : Load_User_Terminal;
TEK4010 : IF MyLoadOverlay( 2, PT4T4010, 'PT4T4010.CHN' ) THEN
BEGIN
Emulate_TEK4010;
UnloadEmulator;
END
ELSE
Terminal_To_Emulate := Ansi;
ELSE;
END (* CASE *);
UNTIL ( PibTerm_Done );
END (* Terminal_Emulations *);
(* ------------------------------------------------------------------------ *)
(* PibTerm --- Main Program *)
(* ------------------------------------------------------------------------ *)
{the jump table procedure and data for this module}
{$I PIBTERM.JMP}
{BIGTURBO support routines}
{$I farctrl.inc}
{$I loadmod.in2}
BEGIN (* PibTerm *)
(* Remember top of stack for later *)
TopOfStack := StackPointer;
(* Get command line parameters *)
Get_Command_Line_Parameters;
(* Initialize Turbo Extender *)
InitializeBigTurbo;
(* Set dynamic overlay areas. *)
(* Term module MUST be present. *)
(* Note: Only done if EMM loading *)
(* NOT to be done. *)
(* Note: Following test done this *)
(* way instead of as *)
(* simple logical assignment*)
(* to avoid checking EMM *)
(* unless '/x' requested. *)
IF Use_EMM_For_Overlays THEN
Use_Emm_For_Overlays := EMMAvailable;
IF ( NOT Use_EMM_For_Overlays ) THEN
BEGIN
MyGetOverlayArea( 0 , '', 32000 + 13500 );
MyGetOverlayArea( 1 , 'PT4TERM.CHN', 0 );
END;
(* Initialize PibTerm *)
InitTerm;
(* Program finished flag *)
PibTerm_Done := FALSE;
(* Begin Terminal Emulation *)
REPEAT
Terminal_Emulations;
UNTIL ( PibTerm_Done );
(* Rewrite dialing directory *)
(* if necessary *)
IF Any_Dialing_Changes THEN
IF MyLoadOverlay( 0 , PT4UTIL, 'PT4UTIL.CHN' ) THEN
Rewrite_Dialing_Directory;
(* Clean up and terminate *)
FiniTerm;
Window( 1, 1, Max_Screen_Col, Max_Screen_Line );
Scroll( 1, Max_Screen_Line, 1, Max_Screen_Col, 0,
LightGray, Black );
GoToXY( 1 , 1 );
END (* PibTerm *).